package com.laoye.big_event.Mapper;

import com.laoye.big_event.Pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.Map;

@Mapper
public interface CategoryMapper {
//    添加文章分类
    @Insert("insert into category(category_name,category_alias,create_user,create_time,update_time) " +
            "values (#{categoryName},#{categoryAlias},#{createUser},now(),now())")
    void addCategory(Category category);

//    获取文章分类列表
    @Select("select*from category where create_user=#{createUser}")
    ArrayList<Category> selectBycreateUser(int createUser);

//    根据ID获取文章分类详情
    @Select("select*from category where id=#{id}")
    Category selectById(int id);

//    更新文章分类
    @Update("update category set category_name=#{categoryName},category_alias=#{categoryAlias},update_time=now()" +
            "where id=#{id}")
    void updateCategory(Category category);

//    根据id删除文章分类
    @Delete("delete from category where id=#{id}")
    void deleteCategory(int id);

    String getCategoryName(Integer categoryid);
}
